myApp.controller('addShop', ['$scope', '$http', function($scope, $http){

	$scope.name = "";
	$scope.phone = "";
	$scope.address = "";
	$scope.addShop = function() {

		if($scope.name === "") {
			alert("请填写名称！");
			return;
		}
		if($scope.phone === "") {
			alert("请填写电话！");
			return;
		}
		if($scope.address === "") {
			alert("请填写地址！");
			return;
		}

		var shopData = {
			"shop.name": $scope.name,
			"shop.phone": $scope.phone, 
			"shop.address": $scope.address
		};

		var postCfg = {
			headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
			transformRequest: function (data) {
				return $.param(data);
			}
		};

		$http.post('addShop', shopData, postCfg).then(function successCallback(response) {
			alert("已添加成功！");
			$scope.name = "";
			$scope.phone = "";
			$scope.address = "";

			console.log("ok：" + response);
		}, function errorCallback(response) {
			alert("添加操作失败！");
			console.log("fail：" + response);
		});

	}

}]);